import Vue from 'vue'
import Router from 'vue-router'
const _import = require('./_import_' + process.env.NODE_ENV)
// in development env not use Lazy Loading,because Lazy Loading too many pages will cause webpack hot update too slow.so only in production use Lazy Loading

/* layout */
import Layout from '../views/layout/Layout'

Vue.use(Router)

 /**
  * icon : the icon show in the sidebar
  * hidden : if `hidden:true` will not show in the sidebar
  * redirect : if `redirect:noredirect` will not redirct in the levelbar
  * noDropdown : if `noDropdown:true` will not has submenu in the sidebar
  * meta : `{ role: ['admin'] }`  will control the page role
  **/
export const constantRouterMap = [
  { path: '/login', component: _import('login/index'), hidden: true },
  { path: '/404', component: _import('errorPage/404'), hidden: true },
  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    name: 'Dashboard',
    hidden: true,
    children: [{ path: 'dashboard', component: _import('dashboard/index') }]
  }
]

export default new Router({
  // mode: 'history', //后端支持可开
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})


export const routerMap = {
  'Layout': Layout,
  'errorPage/404': _import('errorPage/404'),
  'user/OrgManagement': _import('user/OrgManagement'),
  'user/StaffManagement': _import('user/StaffManagement'),
  'permission/RoleManagement': _import('permission/RoleManagement'),
  'permission/AdminManagement': _import('permission/AdminManagement'),
  'server/ServerMonitor': _import('server/ServerMonitor'),
  'server/SNEntry': _import('server/SNEntry'),
  'server/DataBackup': _import('server/DataBackup'),
  'server/RoutingListEdit': _import('server/RoutingListEdit'),
  'application/appEntry/Index': _import('application/appEntry/Index'),
  'application/appEntry/AppInfo': _import('application/appEntry/AppInfo'),
  'application/appEntry/EntryList': _import('application/appEntry/EntryList'),
  'application/appEntry/CreateNewApp': _import('application/appEntry/CreateNewApp'),
  'application/appEntry/uploadApp/Index': _import('application/appEntry/uploadApp/Index'),
  'application/appEntry/uploadApp/UploadFile': _import('application/appEntry/uploadApp/UploadFile'),
  'application/appEntry/uploadApp/completeInfo/Index': _import('application/appEntry/uploadApp/completeInfo/Index'),
  'application/appEntry/uploadApp/completeInfo/S1': _import('application/appEntry/uploadApp/completeInfo/S1'),
  'application/appEntry/uploadApp/completeInfo/S2': _import('application/appEntry/uploadApp/completeInfo/S2'),
  'application/appEntry/uploadApp/completeInfo/S3': _import('application/appEntry/uploadApp/completeInfo/S3'),
  'application/appEntry/appStatus/Index': _import('application/appEntry/appStatus/Index'),
  'application/appEntry/appStatus/Pending': _import('application/appEntry/appStatus/Pending'),
  'application/appEntry/appStatus/Passed': _import('application/appEntry/appStatus/Passed'),
  'application/appEntry/appStatus/Failed': _import('application/appEntry/appStatus/Failed'),
  'application/appReview/Index': _import('application/appReview/Index'),
  'application/appReview/ReviewList': _import('application/appReview/ReviewList'),
  'application/appReview/ReviewPage': _import('application/appReview/ReviewPage'),
  'statistics/User': _import('statistics/User')
}

// export const asyncRouterMap = [
//   {
//     path: '/example',
//     component: Layout,
//     redirect: 'noredirect',
//     name: 'Example',
//     icon: 'zujian',
//     children: [
//       { path: 'index',
//         name: 'Form',
//         icon: 'zonghe',
//         component: _import('page/form'),
//       }
//     ]
//   },
//
//   {
//     path: '/table',
//     component: Layout,
//     redirect: '/table/index',
//     icon: 'tubiao',
//     noDropdown: true,
//     children: [
//       {
//         path: 'index',
//         name: 'Table',
//         component: _import('table/index'),
//         meta: { role: ['admin'] }
//       }
//     ]
//   },
//
//   { path: '*', redirect: '/404', hidden: true }
// ]
